/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bgu.ppm.dat.view;

import bgu.ppm.dat.model.Table;
import java.awt.Dimension;
import java.awt.Image;
import javax.swing.JComponent;

/**
 *
 * @author User
 */
public class PivotTableView extends javax.swing.JPanel implements PivotTableWorkbunchView.TableVisualizationFactory {

    PivotJTableModel model;
    
    
    /**
     * Creates new form PivotTableView
     */
    public PivotTableView() {
        initComponents();

        table.getTableHeader().setVisible(false);
        table.getTableHeader().setPreferredSize(new Dimension(-1, 0));
    }

    public Table getModel() {
        return model.getInnerModel();
    }

    public void setModel(Table model) {
        this.model = new PivotJTableModel(model);
        table.setModel(this.model);
    }
    

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        table = new javax.swing.JTable();

        setLayout(new java.awt.BorderLayout());

        table.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(table);

        add(jScrollPane1, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable table;
    // End of variables declaration//GEN-END:variables

    @Override
    public JComponent getComponent(Table table) {
        setModel(table);
        
        return this;
    }

    @Override
    public String getVisualName() {
        return "Table";
    }

    @Override
    public Image getIcon() {
        return null;
    }

    @Override
    public String getDescription() {
        return "Table";
    }
}
